package com.cc.flyingfish.controller;

import com.cc.flyingfish.service.AuthoritionService;
import com.cc.flyingfish.vo.JwtToken;
import com.cc.flyingfish.vo.UsernameAndPassword;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CHENCHEN
 * @company 北京学佳澳教育科技
 * @create 2023-02-28 15:10
 */
@Slf4j
@RestController
public class AuthoritionController {

    @Autowired
    private AuthoritionService authoritionService;

    @PostMapping("login")
    public JwtToken login(@RequestBody UsernameAndPassword usernameAndPassword) throws Exception {
        log.info("RequestBody param is : [{}]",usernameAndPassword);
        return new JwtToken(authoritionService.loginGetToken(usernameAndPassword));
    }
}
